import request from '@/utils/request'
import requestFile from '@/utils/request-file'
import { formatDateByFmt } from '@/utils/util'

const prefixUrl = 'web/media/'

// 根据点位ID获取锁定点位时间
export function list_lock_media_id(params) {
  return request({
    url: prefixUrl + 'list-lock-media-id',
    method: 'get',
    params
  })
}

// 提交数据
export function submit_manual_lock(data) {
  return request({
    url: prefixUrl + 'submit-manual-lock',
    method: 'post',
    content_type: 'json',
    data
  })
}

// 获取空位Excel
export function export_leave_unused_point_excel(data, params) {
  return requestFile({
    url: prefixUrl + 'export_leave_unused_point_excel',
    method: 'post',
    content_type: 'json',
    data,
    params,
    fileName: '空位导出' + (formatDateByFmt(new Date(), 'yyyyMMddhhmmss') + Math.floor(Math.random() * (
      1000000 -
      1) + 1)) + '.zip'
  })
}

// 释放点位锁定
export function release_manual_lock(params) {
  return request({
    url: prefixUrl + 'release-manual-lock',
    method: 'delete',
    params
  })
}

// 查询所有点位名称 包括代理形式媒体名称
export function list_media_type_include_proxy(params) {
  return request({
    url: prefixUrl + 'list-media-type-include-proxy',
    method: 'get',
    params
  })
}

// 统计
export function page(params) {
  return request({
    url: prefixUrl + 'page',
    method: 'get',
    params
  })
}

